{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"4_SQUAD_GLUE_T5_tasks.ipynb","provenance":[],"collapsed_sections":[]},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"cell_type":"markdown","metadata":{"id":"YcJLn3NGaKIH"},"source":["![JohnSnowLabs](https://nlp.johnsnowlabs.com/assets/images/logo.png)\n","\n","\n","\n","[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/JohnSnowLabs/nlu/blob/master/examples/colab/component_examples/sequence2sequence/T5_tasks_summarize_question_answering_and_more.ipynb)\n","\n","# Overview of every task available with T5\n","[The T5 model](https://arxiv.org/pdf/1910.10683.pdf) is trained on various datasets for 17 different tasks which fall into 8 categories.\n","\n","\n","\n","1. Text summarization\n","2. Question answering\n","3. Translation\n","4. Sentiment analysis\n","5. Natural Language inference\n","6. Coreference resolution\n","7. Sentence Completion\n","8. Word sense disambiguation\n","\n","# Every T5 Task with explanation:\n","|Task Name | Explanation | \n","|----------|--------------|\n","|[1.CoLA](https://nyu-mll.github.io/CoLA/)                   | Classify if a sentence is gramaticaly correct|\n","|[2.RTE](https://dl.acm.org/doi/10.1007/11736790_9)                    | Classify whether if a statement can be deducted from a sentence|\n","|[3.MNLI](https://arxiv.org/abs/1704.05426)                   | Classify for a hypothesis and premise whether they contradict or contradict each other or neither of both (3 class).|\n","|[4.MRPC](https://www.aclweb.org/anthology/I05-5002.pdf)                   | Classify whether a pair of sentences is a re-phrasing of each other (semantically equivalent)|\n","|[5.QNLI](https://arxiv.org/pdf/1804.07461.pdf)                   | Classify whether the answer to a question can be deducted from an answer candidate.|\n","|[6.QQP](https://www.quora.com/q/quoradata/First-Quora-Dataset-Release-Question-Pairs)                    | Classify whether a pair of questions is a re-phrasing of each other (semantically equivalent)|\n","|[7.SST2](https://www.aclweb.org/anthology/D13-1170.pdf)                   | Classify the sentiment of a sentence as positive or negative|\n","|[8.STSB](https://www.aclweb.org/anthology/S17-2001/)                   | Classify the sentiment of a sentence on a scale from 1 to 5 (21 Sentiment classes)|\n","|[9.CB](https://ojs.ub.uni-konstanz.de/sub/index.php/sub/article/view/601)                     | Classify for a premise and a hypothesis whether they contradict each other or not (binary).|\n","|[10.COPA](https://www.aaai.org/ocs/index.php/SSS/SSS11/paper/view/2418/0)                   | Classify for a question, premise, and 2 choices which choice the correct choice is (binary).|\n","|[11.MultiRc](https://www.aclweb.org/anthology/N18-1023.pdf)                | Classify for a question, a paragraph of text, and an answer candidate, if the answer is correct (binary),|\n","|[12.WiC](https://arxiv.org/abs/1808.09121)                    | Classify for a pair of sentences and a disambigous word if the word has the same meaning in both sentences.|\n","|[13.WSC/DPR](https://www.aaai.org/ocs/index.php/KR/KR12/paper/view/4492/0)       | Predict for an ambiguous pronoun in a sentence what it is referring to.  |\n","|[14.Summarization](https://arxiv.org/abs/1506.03340)          | Summarize text into a shorter representation.|\n","|[15.SQuAD](https://arxiv.org/abs/1606.05250)                  | Answer a question for a given context.|\n","|[16.WMT1.](https://arxiv.org/abs/1706.03762)                  | Translate English to German|\n","|[17.WMT2.](https://arxiv.org/abs/1706.03762)                   | Translate English to French|\n","|[18.WMT3.](https://arxiv.org/abs/1706.03762)                   | Translate English to Romanian|\n","\n","\n","# Information about pre-processing for T5 tasks\n","\n","## Tasks that require no pre-processing\n","The following tasks work fine without any additional pre-processing, only setting the `task parameter` on the T5 model is required:\n","\n","-  CoLA\n","-  Summarization\n","-  SST2\n","-  WMT1.\n","-  WMT2.\n","-  WMT3.\n","\n","\n","## Tasks that require pre-processing with 1 tag\n","The following tasks require `exactly 1 additional tag` added by manual pre-processing.\n","Set the `task parameter` and then join the sentences on the `tag` for these tasks.\n","\n","- RTE\n","- MNLI\n","- MRPC\n","- QNLI\n","- QQP\n","- SST2\n","- STSB\n","- CB\n","\n","\n","## Tasks that require pre-processing with multiple tags\n","The following tasks require `more than 1 additional tag` added manual by pre-processing.\n","Set the `task parameter` and then prefix sentences with their corresponding tags and join them for these tasks:\n","\n","- COPA\n","- MultiRc\n","- WiC\n","\n","\n","## WSC/DPR is a special case that requires `*` surrounding\n","The task WSC/DPR requires highlighting a pronoun with `*` and configuring a `task parameter`.\n","<br><br><br><br><br><br><br><br>\n","\n","\n","\n","\n","\n","The following sections describe each task in detail, with an example and also a pre-processed example.\n","\n","***NOTE:***  Linebreaks are added to the `pre-processed examples` in the following section. The T5 model also works with linebreaks, but it can hinder the performance and it is not recommended to intentionally add them.\n","\n","\n","\n","# Task 1 [CoLA - Binary Grammatical Sentence acceptability classification](https://nyu-mll.github.io/CoLA/)\n","Judges if a sentence is grammatically acceptable.     \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","\n","\n","## Example\n","\n","|sentence  | prediction|\n","|------------|------------|\n","| Anna and Mike is going skiing and they is liked is | unacceptable |      \n","| Anna and Mike like to dance | acceptable | \n","\n","\n","## How to configure T5 task for CoLA\n","`.setTask(cola sentence:)` prefix.\n","\n","### Example pre-processed input for T5 CoLA sentence acceptability judgement:\n","```\n","cola \n","sentence: Anna and Mike is going skiing and they is liked is\n","```\n","\n","# Task 2 [RTE - Natural language inference Deduction Classification](https://dl.acm.org/doi/10.1007/11736790_9)\n","The RTE task is defined as recognizing, given two text fragments, whether the meaning of one text can be inferred (entailed) from the other or not.       \n","Classification of sentence pairs as entailed and not_entailed       \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf) and  [SuperGLUE](https://w4ngatang.github.io/static/papers/superglue.pdf).\n","\n","\n","\n","## Example\n","\n","|sentence 1 | sentence 2 | prediction|\n","|------------|------------|----------|\n","Kessler ’s team conducted 60,643 interviews with adults in 14 countries.  |  Kessler ’s team interviewed more than 60,000 adults in 14 countries | entailed\n","Peter loves New York, it is his favorite city| Peter loves new York. | entailed\n","Recent report say Johnny makes he alot of money, he earned 10 million USD each year for the last 5 years.  |Johnny is a millionare | entailment|\n","Recent report say Johnny makes he alot of money, he earned 10 million USD each year for the last 5 years.  |Johnny is a poor man  | not_entailment | \n","| It was raining in England for the last 4 weeks | England was very dry yesterday | not_entailment|\n","\n","\n","## How to configure T5 task for RTE\n","`.setTask('rte sentence1:)` and prefix second sentence with `sentence2:`\n","\n","\n","### Example pre-processed input for T5 RTE - 2 Class Natural language inference\n","```\n","rte \n","sentence1: Recent report say Peter makes he alot of money, he earned 10 million USD each year for the last 5 years. \n","sentence2: Peter is a millionare.\n","```\n","\n","### References\n","- https://arxiv.org/abs/2010.03061\n","\n","\n","# Task 3 [MNLI - 3 Class Natural Language Inference 3-class contradiction classification](https://arxiv.org/abs/1704.05426)\n","Classification of sentence pairs with the labels `entailment`, `contradiction`, and `neutral`.      \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","\n","This classifier predicts for two sentences :\n","- Whether the first sentence logically and semantically follows from the second sentence as entailment\n","- Whether the first sentence is a contradiction to the second sentence as a contradiction\n","- Whether the first sentence does not entail or contradict the first sentence as neutral\n","\n","| Hypothesis | Premise | prediction|\n","|------------|------------|----------|\n","| Recent report say Johnny makes he alot of money, he earned 10 million USD each year for the last 5 years. |    Johnny is a poor man.  | contradiction|\n","|It rained in England the last 4 weeks.| It was snowing in New York last week| neutral | \n","\n","## How to configure T5 task for MNLI\n","`.setTask('mnli hypothesis:)` and prefix second sentence with `premise:`\n","\n","### Example pre-processed input for T5 MNLI - 3 Class Natural Language Inference\n","\n","```\n","mnli \n","hypothesis: At 8:34, the Boston Center controller received a third, transmission from American 11.    \n","premise: The Boston Center controller got a third transmission from American 11.\n","```\n","\n","\n","# Task 4 [MRPC - Binary Paraphrasing/ sentence similarity classification ](https://www.aclweb.org/anthology/I05-5002.pdf)\n","Detect whether one sentence is a re-phrasing or similar to another sentence      \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","\n","| Sentence1 | Sentence2 | prediction|\n","|------------|------------|----------|\n","|We acted because we saw the existing evidence in a new light , through the prism of our experience on 11 September , \" Rumsfeld said .| Rather , the US acted because the administration saw \" existing evidence in a new light , through the prism of our experience on September 11 \" . | equivalent | \n","| I like to eat peanutbutter for breakfast| I like to play football | not_equivalent | \n","\n","\n","## How to configure T5 task for MRPC\n","`.setTask('mrpc sentence1:)` and prefix second sentence with `sentence2:`\n","\n","### Example pre-processed input for T5 MRPC - Binary Paraphrasing/ sentence similarity\n","\n","```\n","mrpc \n","sentence1: We acted because we saw the existing evidence in a new light , through the prism of our experience on 11 September , \" Rumsfeld said . \n","sentence2: Rather , the US acted because the administration saw \" existing evidence in a new light , through the prism of our experience on September 11\",\n","```\n","\n","*ISSUE:* Can only get neutral and contradiction as prediction results for tested samples but no entailment predictions.\n","\n","\n","# Task 5 [QNLI - Natural Language Inference question answered classification](https://arxiv.org/pdf/1804.07461.pdf)\n","Classify whether a question is answered by a sentence (`entailed`).       \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","| Question | Answer | prediction|\n","|------------|------------|----------|\n","|Where did Jebe die?| Ghenkis Khan recalled Subtai back to Mongolia soon afterward, and Jebe died on the road back to Samarkand | entailment|\n","|What does Steve like to eat? | Steve watches TV all day | not_netailment\n","\n","## How to configure T5 task for QNLI - Natural Language Inference question answered classification\n","`.setTask('QNLI sentence1:)` and prefix question with `question:` sentence with `sentence:`:\n","\n","### Example pre-processed input for T5 QNLI - Natural Language Inference question answered classification\n","\n","```\n","qnli\n","question: Where did Jebe die?     \n","sentence: Ghenkis Khan recalled Subtai back to Mongolia soon afterwards, and Jebe died on the road back to Samarkand,\n","```\n","\n","\n","# Task 6 [QQP - Binary Question Similarity/Paraphrasing](https://www.quora.com/q/quoradata/First-Quora-Dataset-Release-Question-Pairs)\n","Based on a quora dataset, determine whether a pair of questions are semantically equivalent.      \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","| Question1 | Question2 | prediction|\n","|------------|------------|----------|\n","|What attributes would have made you highly desirable in ancient Rome?        | How I GET OPPERTINUTY TO JOIN IT COMPANY AS A FRESHER? | not_duplicate | \n","|What was it like in Ancient rome?  | What was Ancient rome like?| duplicate | \n","\n","\n","## How to configure T5 task for QQP\n",".setTask('qqp question1:) and\n","prefix second sentence with question2:\n","\n","\n","### Example pre-processed input for T5 QQP - Binary Question Similarity/Paraphrasing\n","\n","```\n","qqp \n","question1: What attributes would have made you highly desirable in ancient Rome?        \n","question2: How I GET OPPERTINUTY TO JOIN IT COMPANY AS A FRESHER?',\n","```\n","\n","# Task 7 [SST2 - Binary Sentiment Analysis](https://www.aclweb.org/anthology/D13-1170.pdf)\n","Binary sentiment classification.      \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","| Sentence1 | Prediction  | \n","|-----------|-----------|\n","|it confirms fincher ’s status as a film maker who artfully bends technical know-how to the service of psychological insight |  positive| \n","|I really hated that movie | negative | \n","\n","\n","## How to configure T5 task for  SST2\n","`.setTask('sst2 sentence: ')`\n","\n","### Example pre-processed input for T5 SST2 - Binary Sentiment Analysis\n","\n","```\n","sst2\n","sentence: I hated that movie\n","```\n","\n","\n","\n","# Task8 [STSB - Regressive semantic sentence similarity](https://www.aclweb.org/anthology/S17-2001/)\n","Measures how similar two sentences are on a scale from 0 to 5 with 21 classes representing a regressive label.     \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","\n","| Question1 | Question2 | prediction|\n","|------------|------------|----------|\n","|What attributes would have made you highly desirable in ancient Rome?        | How I GET OPPERTINUTY TO JOIN IT COMPANY AS A FRESHER? | 0 | \n","|What was it like in Ancient rome?  | What was Ancient rome like?| 5.0 | \n","|What was live like as a King in Ancient Rome??       | What is it like to live in Rome? | 3.2 | \n","\n","## How to configure T5 task for STSB\n","`.setTask('stsb sentence1:)` and prefix second sentence with `sentence2:`\n","\n","\n","### Example pre-processed input for T5 STSB - Regressive semantic sentence similarity\n","\n","```\n","stsb\n","sentence1: What attributes would have made you highly desirable in ancient Rome?        \n","sentence2: How I GET OPPERTINUTY TO JOIN IT COMPANY AS A FRESHER?',\n","```\n","\n","\n","# Task 9[ CB -  Natural language inference contradiction classification](https://ojs.ub.uni-konstanz.de/sub/index.php/sub/article/view/601)\n","Classify whether a Premise contradicts a Hypothesis.    \n","Predicts entailment, neutral and contradiction     \n","This is a sub-task of [SuperGLUE](https://w4ngatang.github.io/static/papers/superglue.pdf).\n","\n","\n","| Hypothesis | Premise | Prediction | \n","|--------|-------------|----------|\n","|Valence was helping | Valence the void-brain, Valence the virtuous valet. Why couldn’t the figger choose his own portion of titanic anatomy to shaft? Did he think he was helping'| Contradiction|\n","\n","\n","## How to configure T5 task for CB\n","`.setTask('cb hypothesis:)` and prefix premise with `premise:`\n","\n","### Example pre-processed input for T5 CB -  Natural language inference contradiction classification\n","\n","```\n","cb \n","hypothesis: Valence was helping      \n","premise: Valence the void-brain, Valence the virtuous valet. Why couldn’t the figger choose his own portion of titanic anatomy to shaft? Did he think he was helping,\n","```\n","\n","\n","# Task 10 [COPA - Sentence Completion/ Binary choice selection](https://www.aaai.org/ocs/index.php/SSS/SSS11/paper/view/2418/0)\n","The Choice of Plausible Alternatives (COPA) task by Roemmele et al. (2011) evaluates\n","causal reasoning between events, which requires commonsense knowledge about what usually takes\n","place in the world. Each example provides a premise and either asks for the correct cause or effect\n","from two choices, thus testing either ``backward`` or `forward causal reasoning`. COPA data, which\n","consists of 1,000 examples total, can be downloaded at https://people.ict.usc.e\n","\n","This is a sub-task of [SuperGLUE](https://w4ngatang.github.io/static/papers/superglue.pdf).\n","\n","This classifier selects from a choice of `2 options` which one the correct is based on a `premise`.\n","\n","\n","## forward causal reasoning\n","Premise: The man lost his balance on the ladder.     \n","question: What happened as a result?        \n","Alternative 1: He fell off the ladder.       \n","Alternative 2: He climbed up the ladder.\n","## backwards causal reasoning\n","Premise: The man fell unconscious. What was the cause\n","of this?       \n","Alternative 1: The assailant struck the man in the head.      \n","Alternative 2: The assailant took the man’s wallet.\n","\n","\n","| Question | Premise | Choice 1 | Choice  2 | Prediction | \n","|--------|-------------|----------|---------|-------------|\n","|effect | Politcal Violence broke out in the nation. | many citizens relocated to the capitol. |  Many citizens took refuge in other territories | Choice 1  | \n","|correct| The men fell unconscious | The assailant struckl the man in the head | he assailant s took the man's wallet. | choice1 | \n","\n","\n","## How to configure T5 task for COPA\n","`.setTask('copa choice1:)`, prefix choice2 with `choice2:` , prefix premise with `premise:` and prefix the question with `question`\n","\n","### Example pre-processed input for T5 COPA - Sentence Completion/ Binary choice selection\n","\n","```\n","copa \n","choice1:   He fell off the ladder    \n","choice2:   He climbed up the lader       \n","premise:   The man lost his balance on the ladder \n","question:  effect\n","```\n","\n","\n","\n","\n","# Task 11 [MultiRc - Question Answering](https://www.aclweb.org/anthology/N18-1023.pdf)\n","Evaluates an `answer` for a `question` as `true` or `false` based on an input `paragraph`\n","The T5 model predicts for a `question` and a `paragraph` of `sentences` wether an `answer` is true or not,\n","based on the semantic contents of the paragraph.        \n","This is a sub-task of [SuperGLUE](https://w4ngatang.github.io/static/papers/superglue.pdf).\n","\n","\n","\n","**Exeeds human performance by a large margin**\n","\n","\n","\n","| Question                                                     | Answer                                                              | Prediction | paragraph|\n","|--------------------------------------------------------------|---------------------------------------------------------------------|------------|----------|\n","| Why was Joey surprised the morning he woke up for breakfast? | There was only pie to eat, rather than traditional breakfast foods  |  True   |Once upon a time, there was a squirrel named Joey. Joey loved to go outside and play with his cousin Jimmy. Joey and Jimmy played silly games together, and were always laughing. One day, Joey and Jimmy went swimming together 50 at their Aunt Julie’s pond. Joey woke up early in the morning to eat some food before they left. He couldn’t find anything to eat except for pie! Usually, Joey would eat cereal, fruit (a pear), or oatmeal for breakfast. After he ate, he and Jimmy went to the pond. On their way there they saw their friend Jack Rabbit. They dove into the water and swam for several hours. The sun was out, but the breeze was cold. Joey and Jimmy got out of the water and started walking home. Their fur was wet, and the breeze chilled them. When they got home, they dried off, and Jimmy put on his favorite purple shirt. Joey put on a blue shirt with red and green dots. The two squirrels ate some food that Joey’s mom, Jasmine, made and went off to bed.,          |\n","| Why was Joey surprised the morning he woke up for breakfast? | There was a T-Rex in his garden  |  False   |Once upon a time, there was a squirrel named Joey. Joey loved to go outside and play with his cousin Jimmy. Joey and Jimmy played silly games together, and were always laughing. One day, Joey and Jimmy went swimming together 50 at their Aunt Julie’s pond. Joey woke up early in the morning to eat some food before they left. He couldn’t find anything to eat except for pie! Usually, Joey would eat cereal, fruit (a pear), or oatmeal for breakfast. After he ate, he and Jimmy went to the pond. On their way there they saw their friend Jack Rabbit. They dove into the water and swam for several hours. The sun was out, but the breeze was cold. Joey and Jimmy got out of the water and started walking home. Their fur was wet, and the breeze chilled them. When they got home, they dried off, and Jimmy put on his favorite purple shirt. Joey put on a blue shirt with red and green dots. The two squirrels ate some food that Joey’s mom, Jasmine, made and went off to bed.,          |\n","\n","## How to configure T5 task for MultiRC\n","`.setTask('multirc questions:)`  followed by `answer:` prefix for the answer to evaluate, followed by `paragraph:` and then a series of sentences, where each sentence is prefixed with `Sent n:`prefix second sentence with sentence2:\n","\n","\n","### Example pre-processed input for T5 MultiRc task:\n","```\n","multirc questions:  Why was Joey surprised the morning he woke up for breakfast?      \n","answer:             There was a T-REX in his garden.      \n","paragraph:      \n","Sent 1:             Once upon a time, there was a squirrel named Joey.      \n","Sent 2:             Joey loved to go outside and play with his cousin Jimmy.      \n","Sent 3:             Joey and Jimmy played silly games together, and were always laughing.      \n","Sent 4:             One day, Joey and Jimmy went swimming together 50 at their Aunt Julie’s pond.      \n","Sent 5:             Joey woke up early in the morning to eat some food before they left.      \n","Sent 6:             He couldn’t find anything to eat except for pie!      \n","Sent 7:             Usually, Joey would eat cereal, fruit (a pear), or oatmeal for breakfast.      \n","Sent 8:             After he ate, he and Jimmy went to the pond.      \n","Sent 9:             On their way there they saw their friend Jack Rabbit.      \n","Sent 10:            They dove into the water and swam for several hours.      \n","Sent 11:            The sun was out, but the breeze was cold.      \n","Sent 12:            Joey and Jimmy got out of the water and started walking home.      \n","Sent 13:            Their fur was wet, and the breeze chilled them.      \n","Sent 14:            When they got home, they dried off, and Jimmy put on his favorite purple shirt.      \n","Sent 15:            Joey put on a blue shirt with red and green dots.      \n","Sent 16:            The two squirrels ate some food that Joey’s mom, Jasmine, made and went off to bed.      \n","```\n","\n","\n","# Task 12 [WiC - Word sense disambiguation](https://arxiv.org/abs/1808.09121)\n","Decide for `two sentence`s with a shared `disambigous word` wether they have the target word has the same `semantic meaning` in both sentences.       \n","This is a sub-task of [SuperGLUE](https://w4ngatang.github.io/static/papers/superglue.pdf).\n","\n","\n","|Predicted | disambigous word| Sentence 1 | Sentence 2 | \n","|----------|-----------------|------------|------------|\n","| False    | kill            | He totally killed that rock show! | The airplane crash killed his family | \n","| True     | window          | The expanded window will give us time to catch the thieves.|You have a two-hour window for turning in your homework. |     \n","| False     | window          | He jumped out of the window.|You have a two-hour window for turning in your homework. |     \n","\n","\n","## How to configure T5 task for MultiRC\n","`.setTask('wic pos:)`  followed by `sentence1:` prefix for the first sentence, followed by `sentence2:` prefix for the second sentence.\n","\n","\n","### Example pre-processed input for T5  WiC task:\n","\n","```\n","wic pos:\n","sentence1:    The expanded window will give us time to catch the thieves.\n","sentence2:    You have a two-hour window of turning in your homework.\n","word :        window\n","```\n","\n","\n","\n","# Task 13 [WSC and DPR - Coreference resolution/ Pronoun ambiguity resolver  ](https://www.aaai.org/ocs/index.php/KR/KR12/paper/view/4492/0)\n","Predict for an `ambiguous pronoun` to which `noun` it is referring to.     \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf) and [SuperGLUE](https://w4ngatang.github.io/static/papers/superglue.pdf).\n","\n","|Prediction| Text | \n","|----------|-------|\n","| stable   | The stable was very roomy, with four good stalls; a large swinging window opened into the yard , which made *it* pleasant and airy. | \n","\n","\n","\n","## How to configure T5 task for WSC/DPR\n","`.setTask('wsc:)` and surround pronoun with asteriks symbols..\n","\n","\n","### Example pre-processed input for T5  WSC/DPR  task:\n","The `ambiguous pronous` should be surrounded with `*` symbols.\n","\n","***Note*** Read [Appendix A.](https://arxiv.org/pdf/1910.10683.pdf#page=64&zoom=100,84,360) for more info\n","```\n","wsc: \n","The stable was very roomy, with four good stalls; a large swinging window opened into the yard , which made *it* pleasant and airy.\n","```\n","\n","\n","# Task 14 [Text summarization](https://arxiv.org/abs/1506.03340)\n","`Summarizes` a paragraph into a shorter version with the same semantic meaning.\n","\n","| Predicted summary| Text | \n","|------------------|-------|\n","| manchester united face newcastle in the premier league on wednesday . louis van gaal's side currently sit two points clear of liverpool in fourth . the belgian duo took to the dance floor on monday night with some friends .            | the belgian duo took to the dance floor on monday night with some friends . manchester united face newcastle in the premier league on wednesday . red devils will be looking for just their second league away win in seven . louis van gaal’s side currently sit two points clear of liverpool in fourth . | \n","\n","\n","## How to configure T5 task for summarization\n","`.setTask('summarize:)`\n","\n","\n","### Example pre-processed input for T5 summarization task:\n","This task requires no pre-processing, setting the task to `summarize` is sufficient.\n","```\n","the belgian duo took to the dance floor on monday night with some friends . manchester united face newcastle in the premier league on wednesday . red devils will be looking for just their second league away win in seven . louis van gaal’s side currently sit two points clear of liverpool in fourth .\n","```\n","\n","# Task 15 [SQuAD - Context based question answering](https://arxiv.org/abs/1606.05250)\n","Predict an `answer` to a `question` based on input `context`.\n","\n","|Predicted Answer | Question | Context | \n","|-----------------|----------|------|\n","|carbon monoxide| What does increased oxygen concentrations in the patient’s lungs displace? | Hyperbaric (high-pressure) medicine uses special oxygen chambers to increase the partial pressure of O 2 around the patient and, when needed, the medical staff. Carbon monoxide poisoning, gas gangrene, and decompression sickness (the ’bends’) are sometimes treated using these devices. Increased O 2 concentration in the lungs helps to displace carbon monoxide from the heme group of hemoglobin. Oxygen gas is poisonous to the anaerobic bacteria that cause gas gangrene, so increasing its partial pressure helps kill them. Decompression sickness occurs in divers who decompress too quickly after a dive, resulting in bubbles of inert gas, mostly nitrogen and helium, forming in their blood. Increasing the pressure of O 2 as soon as possible is part of the treatment.\n","|pie| What did Joey eat for breakfast?| Once upon a time, there was a squirrel named Joey. Joey loved to go outside and play with his cousin Jimmy. Joey and Jimmy played silly games together, and were always laughing. One day, Joey and Jimmy went swimming together 50 at their Aunt Julie’s pond. Joey woke up early in the morning to eat some food before they left. Usually, Joey would eat cereal, fruit (a pear), or oatmeal for breakfast. After he ate, he and Jimmy went to the pond. On their way there they saw their friend Jack Rabbit. They dove into the water and swam for several hours. The sun was out, but the breeze was cold. Joey and Jimmy got out of the water and started walking home. Their fur was wet, and the breeze chilled them. When they got home, they dried off, and Jimmy put on his favorite purple shirt. Joey put on a blue shirt with red and green dots. The two squirrels ate some food that Joey’s mom, Jasmine, made and went off to bed,'|  \n","\n","## How to configure T5 task parameter for Squad Context based question answering\n","`.setTask('question:)` and prefix the context which can be made up of multiple sentences with `context:`\n","\n","## Example pre-processed input for T5 Squad Context based question answering:\n","```\n","question: What does increased oxygen concentrations in the patient’s lungs displace? \n","context: Hyperbaric (high-pressure) medicine uses special oxygen chambers to increase the partial pressure of O 2 around the patient and, when needed, the medical staff. Carbon monoxide poisoning, gas gangrene, and decompression sickness (the ’bends’) are sometimes treated using these devices. Increased O 2 concentration in the lungs helps to displace carbon monoxide from the heme group of hemoglobin. Oxygen gas is poisonous to the anaerobic bacteria that cause gas gangrene, so increasing its partial pressure helps kill them. Decompression sickness occurs in divers who decompress too quickly after a dive, resulting in bubbles of inert gas, mostly nitrogen and helium, forming in their blood. Increasing the pressure of O 2 as soon as possible is part of the treatment.\n","```\n","\n","\n","\n","# Task 16 [WMT1 Translate English to German](https://arxiv.org/abs/1706.03762)\n","For translation tasks use the `marian` model\n","## How to configure T5 task parameter for WMT Translate English to German\n","`.setTask('translate English to German:)`\n","\n","# Task 17 [WMT2 Translate English to French](https://arxiv.org/abs/1706.03762)\n","For translation tasks use the `marian` model\n","## How to configure T5 task parameter for WMT Translate English to French\n","`.setTask('translate English to French:)`\n","\n","\n","# 18 [WMT3 - Translate English to Romanian](https://arxiv.org/abs/1706.03762)\n","For translation tasks use the `marian` model\n","## How to configure T5 task parameter for English to Romanian\n","`.setTask('translate English to Romanian:)`\n"]},{"cell_type":"markdown","metadata":{"id":"l73NeLo6r71r"},"source":["# Spark-NLP Example for every Task:\n","\n","\n","# 0.1 Install Spark NLP and NLU"]},{"cell_type":"code","metadata":{"id":"sDSc7ZPkajRW","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1650022947541,"user_tz":-300,"elapsed":105884,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}},"outputId":"21b225bd-b5ee-44b5-cdda-d42555a2e712"},"source":["!wget https://setup.johnsnowlabs.com/nlu/colab.sh -O - | bash\n","import nlu"],"execution_count":1,"outputs":[{"output_type":"stream","name":"stdout","text":["--2022-04-15 11:40:40--  https://setup.johnsnowlabs.com/nlu/colab.sh\n","Resolving setup.johnsnowlabs.com (setup.johnsnowlabs.com)... 51.158.130.125\n","Connecting to setup.johnsnowlabs.com (setup.johnsnowlabs.com)|51.158.130.125|:443... connected.\n","HTTP request sent, awaiting response... 302 Moved Temporarily\n","Location: https://raw.githubusercontent.com/JohnSnowLabs/nlu/master/scripts/colab_setup.sh [following]\n","--2022-04-15 11:40:41--  https://raw.githubusercontent.com/JohnSnowLabs/nlu/master/scripts/colab_setup.sh\n","Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.110.133, 185.199.108.133, ...\n","Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.\n","HTTP request sent, awaiting response... 200 OK\n","Length: 1665 (1.6K) [text/plain]\n","Saving to: ‘STDOUT’\n","\n","-                   100%[===================>]   1.63K  --.-KB/s    in 0s      \n","\n","2022-04-15 11:40:41 (11.3 MB/s) - written to stdout [1665/1665]\n","\n","Installing  NLU 3.4.3rc2 with  PySpark 3.0.3 and Spark NLP 3.4.2 for Google Colab ...\n","Get:1 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ InRelease [3,626 B]\n","Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]\n","Hit:3 http://archive.ubuntu.com/ubuntu bionic InRelease\n","Ign:4 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  InRelease\n","Get:5 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]\n","Ign:6 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64  InRelease\n","Get:7 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  Release [696 B]\n","Hit:8 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64  Release\n","Get:9 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  Release.gpg [836 B]\n","Get:10 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu bionic InRelease [15.9 kB]\n","Get:11 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]\n","Hit:12 http://ppa.launchpad.net/cran/libgit2/ubuntu bionic InRelease\n","Get:13 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic InRelease [15.9 kB]\n","Get:14 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [2,695 kB]\n","Hit:16 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic InRelease\n","Get:17 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1,490 kB]\n","Get:18 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  Packages [953 kB]\n","Get:19 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [2,268 kB]\n","Get:20 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [3,134 kB]\n","Get:21 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu bionic/main Sources [1,947 kB]\n","Get:22 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu bionic/main amd64 Packages [996 kB]\n","Get:23 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic/main amd64 Packages [45.3 kB]\n","Fetched 13.8 MB in 5s (2,788 kB/s)\n","Reading package lists... Done\n","tar: spark-3.0.2-bin-hadoop2.7.tgz: Cannot open: No such file or directory\n","tar: Error is not recoverable: exiting now\n","\u001b[K     |████████████████████████████████| 209.1 MB 53 kB/s \n","\u001b[K     |████████████████████████████████| 142 kB 44.8 MB/s \n","\u001b[K     |████████████████████████████████| 505 kB 46.9 MB/s \n","\u001b[K     |████████████████████████████████| 198 kB 58.7 MB/s \n","\u001b[?25h  Building wheel for pyspark (setup.py) ... \u001b[?25l\u001b[?25hdone\n","Collecting nlu_tmp==3.4.3rc10\n","  Downloading nlu_tmp-3.4.3rc10-py3-none-any.whl (510 kB)\n","\u001b[K     |████████████████████████████████| 510 kB 5.5 MB/s \n","\u001b[?25hRequirement already satisfied: pandas>=1.3.5 in /usr/local/lib/python3.7/dist-packages (from nlu_tmp==3.4.3rc10) (1.3.5)\n","Requirement already satisfied: dataclasses in /usr/local/lib/python3.7/dist-packages (from nlu_tmp==3.4.3rc10) (0.6)\n","Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from nlu_tmp==3.4.3rc10) (1.21.5)\n","Requirement already satisfied: pyarrow>=0.16.0 in /usr/local/lib/python3.7/dist-packages (from nlu_tmp==3.4.3rc10) (6.0.1)\n","Requirement already satisfied: spark-nlp<3.5.0,>=3.4.2 in /usr/local/lib/python3.7/dist-packages (from nlu_tmp==3.4.3rc10) (3.4.2)\n","Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=1.3.5->nlu_tmp==3.4.3rc10) (2.8.2)\n","Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=1.3.5->nlu_tmp==3.4.3rc10) (2018.9)\n","Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.7.3->pandas>=1.3.5->nlu_tmp==3.4.3rc10) (1.15.0)\n","Installing collected packages: nlu-tmp\n","Successfully installed nlu-tmp-3.4.3rc10\n"]}]},{"cell_type":"markdown","metadata":{"id":"zRfTmN5Rp59D"},"source":["## 0.2 Define Document assembler and T5 model for running the tasks"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"3fJqtnZtaDpd","outputId":"08a017d3-5013-4f62-8a76-88afef3670d7","executionInfo":{"status":"ok","timestamp":1650023070068,"user_tz":-300,"elapsed":122539,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["t5 = nlu.load('en.t5.base')"],"execution_count":2,"outputs":[{"output_type":"stream","name":"stdout","text":["t5_base download started this may take some time.\n","Approximate size to download 446 MB\n","[OK!]\n"]}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"88eNPgivmCTl","outputId":"c7b1e228-e4cb-4ac6-876c-a6c7fee3bb47","executionInfo":{"status":"ok","timestamp":1650023070073,"user_tz":-300,"elapsed":56,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["t5.print_info()"],"execution_count":3,"outputs":[{"output_type":"stream","name":"stdout","text":["The following parameters are configurable for this NLU pipeline (You can copy paste the examples) :\n",">>> component_list['t5_transformer'] has settable params:\n","component_list['t5_transformer'].setBatchSize(1)               | Info: Size of every batch | Currently set to : 1\n","component_list['t5_transformer'].setDoSample(False)            | Info: Whether or not to use sampling; use greedy decoding otherwise | Currently set to : False\n","component_list['t5_transformer'].setIgnoreTokenIds([])         | Info: A list of token ids which are ignored in the decoder's output | Currently set to : []\n","component_list['t5_transformer'].setMaxOutputLength(20)        | Info: Maximum length of output text | Currently set to : 20\n","component_list['t5_transformer'].setMinOutputLength(0)         | Info: Minimum length of the sequence to be generated | Currently set to : 0\n","component_list['t5_transformer'].setNoRepeatNgramSize(0)       | Info: If set to int > 0, all ngrams of that size can only occur once | Currently set to : 0\n","component_list['t5_transformer'].setRepetitionPenalty(1.0)     | Info: The parameter for repetition penalty. 1.0 means no penalty. See `this paper <https://arxiv.org/pdf/1909.05858.pdf>`__ for more details | Currently set to : 1.0\n","component_list['t5_transformer'].setTask('')                   | Info: Transformer's task, e.g. summarize> | Currently set to : \n","component_list['t5_transformer'].setTemperature(1.0)           | Info: The value used to module the next token probabilities | Currently set to : 1.0\n","component_list['t5_transformer'].setTopK(50)                   | Info: The number of highest probability vocabulary tokens to keep for top-k-filtering | Currently set to : 50\n","component_list['t5_transformer'].setTopP(1.0)                  | Info: If set to float < 1, only the most probable tokens with probabilities that add up to ``top_p`` or higher are kept for generation | Currently set to : 1.0\n",">>> component_list['document_assembler'] has settable params:\n","component_list['document_assembler'].setCleanupMode('shrink')  | Info: possible values: disabled, inplace, inplace_full, shrink, shrink_full, each, each_full, delete_full | Currently set to : shrink\n"]}]},{"cell_type":"markdown","metadata":{"id":"KBKk3WWFabhn"},"source":["\n","# Task 1 [CoLA - Binary Grammatical Sentence acceptability classification](https://nyu-mll.github.io/CoLA/)\n","Judges if a sentence is grammatically acceptable.     \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","\n","\n","## Example\n","\n","|sentence  | prediction|\n","|------------|------------|\n","| Anna and Mike is going skiing and they is liked is | unacceptable |      \n","| Anna and Mike like to dance | acceptable | \n","\n","## How to configure T5 task for CoLA\n","`.setTask(cola sentence:)` prefix.\n","\n","### Example pre-processed input for T5 CoLA sentence acceptability judgement:\n","```\n","cola \n","sentence: Anna and Mike is going skiing and they is liked is\n","```"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":112},"id":"roTo1IGqaayd","outputId":"c72d6f02-8103-45f0-f537-8f8a153c1df0","executionInfo":{"status":"ok","timestamp":1650023228903,"user_tz":-300,"elapsed":10965,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('cola sentence: ') \n","\n","# define Data\n","data = ['Anna and Mike is going skiing and they is liked is','Anna and Mike like to dance']\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":5,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document            t5\n","0  Anna and Mike is going skiing and they is like...  unacceptable\n","1                        Anna and Mike like to dance    acceptable"],"text/html":["\n","  <div id=\"df-c0c31cb2-6e83-4807-98db-0980194a20fc\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>Anna and Mike is going skiing and they is like...</td>\n","      <td>unacceptable</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>Anna and Mike like to dance</td>\n","      <td>acceptable</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-c0c31cb2-6e83-4807-98db-0980194a20fc')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-c0c31cb2-6e83-4807-98db-0980194a20fc button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-c0c31cb2-6e83-4807-98db-0980194a20fc');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":5}]},{"cell_type":"markdown","metadata":{"id":"FeSXp9bVio-T"},"source":["# Task 2 [RTE - Natural language inference Deduction Classification](https://dl.acm.org/doi/10.1007/11736790_9)\n","The RTE task is defined as recognizing, given two text fragments, whether the meaning of one text can be inferred (entailed) from the other or not.       \n","Classification of sentence pairs as entailed and not_entailed       \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf) and  [SuperGLUE](https://w4ngatang.github.io/static/papers/superglue.pdf).\n","\n","\n","\n","## Example\n","\n","|sentence 1 | sentence 2 | prediction|\n","|------------|------------|----------|\n","Kessler ’s team conducted 60,643 interviews with adults in 14 countries.  |  Kessler ’s team interviewed more than 60,000 adults in 14 countries | entailed\n","Peter loves New York, it is his favorite city| Peter loves new York. | entailed\n","Recent report say Johnny makes he alot of money, he earned 10 million USD each year for the last 5 years.  |Johnny is a millionare | entailment|\n","Recent report say Johnny makes he alot of money, he earned 10 million USD each year for the last 5 years.  |Johnny is a poor man  | not_entailment | \n","| It was raining in England for the last 4 weeks | England was very dry yesterday | not_entailment|\n","\n","## How to configure T5 task for RTE\n","`.setTask('rte sentence1:)` and prefix second sentence with `sentence2:`\n","\n","\n","### Example pre-processed input for T5 RTE - 2 Class Natural language inference\n","```\n","rte \n","sentence1: Recent report say Peter makes he alot of money, he earned 10 million USD each year for the last 5 years. \n","sentence2: Peter is a millionare.\n","```\n","\n","### References\n","- https://arxiv.org/abs/2010.03061\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":112},"id":"azVTmLRHf_tO","outputId":"16b53076-da88-4822-ac16-ee9f1fcbd5e3","executionInfo":{"status":"ok","timestamp":1650023233184,"user_tz":-300,"elapsed":4306,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","\n","t5['t5_transformer'].setTask('rte sentence: ') \n","\n","data = [\n","             'Recent report say Peter makes he alot of money, he earned 10 million USD each year for the last 5 years.  sentence2: Peter is a millionare',\n","             'Recent report say Peter makes he alot of money, he earned 10 million USD each year for the last 5 years.  sentence2: Peter is a poor man']\n","             \n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":6,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document              t5\n","0  Recent report say Peter makes he alot of money...      entailment\n","1  Recent report say Peter makes he alot of money...  not_entailment"],"text/html":["\n","  <div id=\"df-d777e37a-5f99-40b2-a5bd-2ddc727e395d\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>Recent report say Peter makes he alot of money...</td>\n","      <td>entailment</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>Recent report say Peter makes he alot of money...</td>\n","      <td>not_entailment</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-d777e37a-5f99-40b2-a5bd-2ddc727e395d')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-d777e37a-5f99-40b2-a5bd-2ddc727e395d button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-d777e37a-5f99-40b2-a5bd-2ddc727e395d');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":6}]},{"cell_type":"markdown","metadata":{"id":"4SnQfLLIjZjG"},"source":["\n","# Task 3 [MNLI - 3 Class Natural Language Inference 3-class contradiction classification](https://arxiv.org/abs/1704.05426)\n","Classification of sentence pairs with the labels `entailment`, `contradiction`, and `neutral`.      \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","\n","This classifier predicts for two sentences :\n","- Whether the first sentence logically and semantically follows from the second sentence as entailment\n","- Whether the first sentence is a contradiction to the second sentence as a contradiction\n","- Whether the first sentence does not entail or contradict the first sentence as neutral\n","\n","| Hypothesis | Premise | prediction|\n","|------------|------------|----------|\n","| Recent report say Johnny makes he alot of money, he earned 10 million USD each year for the last 5 years. |    Johnny is a poor man.  | contradiction|\n","|It rained in England the last 4 weeks.| It was snowing in New York last week| neutral | \n","\n","## How to configure T5 task for MNLI\n","`.setTask('mnli hypothesis:)` and prefix second sentence with `premise:`\n","\n","### Example pre-processed input for T5 MNLI - 3 Class Natural Language Inference\n","\n","```\n","mnli \n","hypothesis: At 8:34, the Boston Center controller received a third, transmission from American 11.    \n","premise: The Boston Center controller got a third transmission from American 11.\n","```"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":112},"id":"PP_-VKIojMUh","outputId":"35f4e184-37ee-4dca-fbb2-e2e63610fdad","executionInfo":{"status":"ok","timestamp":1650023233938,"user_tz":-300,"elapsed":772,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('mnli ') \n","\n","\n","# define Data, add additional tags between sentences\n","data = [\n","             \n","              ''' hypothesis: At 8:34, the Boston Center controller received a third, transmission from American 11.\n","                  premise: The Boston Center controller got a third transmission from American 11.\n","              '''\n","             ,\n","             '''  \n","              hypothesis: Recent report say Johnny makes he alot of money, he earned 10 million USD each year for the last 5 years.\n","              premise: Johnny is a poor man.\n","              '''\n","\n","             ]\n","# Set the task on T5\n","\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":7,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document             t5\n","0  hypothesis: At 8:34, the Boston Center control...        neutral\n","1  hypothesis: Recent report say Johnny makes he ...  contradiction"],"text/html":["\n","  <div id=\"df-38d6c817-47fc-433e-860d-faca41fbd5f9\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>hypothesis: At 8:34, the Boston Center control...</td>\n","      <td>neutral</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>hypothesis: Recent report say Johnny makes he ...</td>\n","      <td>contradiction</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-38d6c817-47fc-433e-860d-faca41fbd5f9')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-38d6c817-47fc-433e-860d-faca41fbd5f9 button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-38d6c817-47fc-433e-860d-faca41fbd5f9');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":7}]},{"cell_type":"markdown","metadata":{"id":"FDaoLg8Dkj8W"},"source":["\n","# Task 4 [MRPC - Binary Paraphrasing/ sentence similarity classification ](https://www.aclweb.org/anthology/I05-5002.pdf)\n","Detect whether one sentence is a re-phrasing or similar to another sentence      \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","\n","| Sentence1 | Sentence2 | prediction|\n","|------------|------------|----------|\n","|We acted because we saw the existing evidence in a new light , through the prism of our experience on 11 September , \" Rumsfeld said .| Rather , the US acted because the administration saw \" existing evidence in a new light , through the prism of our experience on September 11 \" . | equivalent | \n","| I like to eat peanutbutter for breakfast| I like to play football | not_equivalent | \n","\n","\n","## How to configure T5 task for MRPC\n","`.setTask('mrpc sentence1:)` and prefix second sentence with `sentence2:`\n","\n","### Example pre-processed input for T5 MRPC - Binary Paraphrasing/ sentence similarity\n","\n","```\n","mrpc \n","sentence1: We acted because we saw the existing evidence in a new light , through the prism of our experience on 11 September , \" Rumsfeld said . \n","sentence2: Rather , the US acted because the administration saw \" existing evidence in a new light , through the prism of our experience on September 11\",\n","```\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":112},"id":"KmRnjdDBkFJf","outputId":"74592939-80fa-4f1c-dfe7-e35f346345fe","executionInfo":{"status":"ok","timestamp":1650023237184,"user_tz":-300,"elapsed":2861,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('mrpc ') \n","\n","# define Data, add additional tags between sentences\n","data = [\n","              ''' sentence1: We acted because we saw the existing evidence in a new light , through the prism of our experience on 11 September , \" Rumsfeld said .\n","                  sentence2: Rather , the US acted because the administration saw \" existing evidence in a new light , through the prism of our experience on September 11 \" \n","              '''\n","             ,\n","             '''  \n","              sentence1: I like to eat peanutbutter for breakfast\n","              sentence2: \tI like to play football.\n","              '''\n","             ]\n","\n","\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":8,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document              t5\n","0  sentence1: We acted because we saw the existin...      equivalent\n","1  sentence1: I like to eat peanutbutter for brea...  not_equivalent"],"text/html":["\n","  <div id=\"df-66139ee9-2749-426c-af1b-f1c91f4b7ac1\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>sentence1: We acted because we saw the existin...</td>\n","      <td>equivalent</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>sentence1: I like to eat peanutbutter for brea...</td>\n","      <td>not_equivalent</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-66139ee9-2749-426c-af1b-f1c91f4b7ac1')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-66139ee9-2749-426c-af1b-f1c91f4b7ac1 button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-66139ee9-2749-426c-af1b-f1c91f4b7ac1');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":8}]},{"cell_type":"markdown","metadata":{"id":"pHcRyNahk8x-"},"source":["\n","# Task 5 [QNLI - Natural Language Inference question answered classification](https://arxiv.org/pdf/1804.07461.pdf)\n","Classify whether a question is answered by a sentence (`entailed`).       \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","| Question | Answer | prediction|\n","|------------|------------|----------|\n","|Where did Jebe die?| Ghenkis Khan recalled Subtai back to Mongolia soon afterward, and Jebe died on the road back to Samarkand | entailment|\n","|What does Steve like to eat? | Steve watches TV all day | not_netailment\n","\n","## How to configure T5 task for QNLI - Natural Language Inference question answered classification\n","`.setTask('QNLI sentence1:)` and prefix question with `question:` sentence with `sentence:`:\n","\n","### Example pre-processed input for T5 QNLI - Natural Language Inference question answered classification\n","\n","```\n","qnli\n","question: Where did Jebe die?     \n","sentence: Ghenkis Khan recalled Subtai back to Mongolia soon afterwards, and Jebe died on the road back to Samarkand,\n","```\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":112},"id":"JGG9z8Vmk4zJ","outputId":"b9cfbb85-0c41-4ca0-b930-d532419298c2","executionInfo":{"status":"ok","timestamp":1650023240501,"user_tz":-300,"elapsed":3323,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('QNLI ') \n","\n","# define Data, add additional tags between sentences\n","data = [\n","              ''' question:  Where did Jebe die?    \n","                  sentence: Ghenkis Khan recalled Subtai back to Mongolia soon afterwards, and Jebe died on the road back to Samarkand,\n","              '''\n","            ,\n","             '''  \n","              question: What does Steve like to eat?\t\n","              sentence: \tSteve watches TV all day\n","              '''\n","\n","             ]\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":9,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document              t5\n","0  question: Where did Jebe die? sentence: Ghenki...      entailment\n","1  question: What does Steve like to eat? sentenc...  not_entailment"],"text/html":["\n","  <div id=\"df-2c0dc481-aa84-42b0-afc8-5977a1f45eaa\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>question: Where did Jebe die? sentence: Ghenki...</td>\n","      <td>entailment</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>question: What does Steve like to eat? sentenc...</td>\n","      <td>not_entailment</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-2c0dc481-aa84-42b0-afc8-5977a1f45eaa')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-2c0dc481-aa84-42b0-afc8-5977a1f45eaa button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-2c0dc481-aa84-42b0-afc8-5977a1f45eaa');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":9}]},{"cell_type":"markdown","metadata":{"id":"lzBXz5calRkP"},"source":["\n","# Task 6 [QQP - Binary Question Similarity/Paraphrasing](https://www.quora.com/q/quoradata/First-Quora-Dataset-Release-Question-Pairs)\n","Based on a quora dataset, determine whether a pair of questions are semantically equivalent.      \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","| Question1 | Question2 | prediction|\n","|------------|------------|----------|\n","|What attributes would have made you highly desirable in ancient Rome?        | How I GET OPPERTINUTY TO JOIN IT COMPANY AS A FRESHER? | not_duplicate | \n","|What was it like in Ancient rome?  | What was Ancient rome like?| duplicate | \n","\n","\n","## How to configure T5 task for QQP\n",".setTask('qqp question1:) and\n","prefix second sentence with question2:\n","\n","\n","### Example pre-processed input for T5 QQP - Binary Question Similarity/Paraphrasing\n","\n","```\n","qqp \n","question1: What attributes would have made you highly desirable in ancient Rome?        \n","question2: How I GET OPPERTINUTY TO JOIN IT COMPANY AS A FRESHER?',\n","```"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":112},"id":"2WWW-0X6lRJT","outputId":"5aaa1de0-07e4-4db9-f8d8-db92400ddf33","executionInfo":{"status":"ok","timestamp":1650023243070,"user_tz":-300,"elapsed":2613,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('qqp ') \n","\n","\n","# define Data, add additional tags between sentences\n","data = [\n","              ''' question1:  What attributes would have made you highly desirable in ancient Rome?    \n","                  question2:  How I GET OPPERTINUTY TO JOIN IT COMPANY AS A FRESHER?'\n","              '''\n","             ,\n","             '''  \n","              question1: What was it like in Ancient rome?\n","              question2: \tWhat was Ancient rome like?\n","              '''\n","\n","             ]\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":10,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document             t5\n","0  question1: What attributes would have made you...  not_duplicate\n","1  question1: What was it like in Ancient rome? q...      duplicate"],"text/html":["\n","  <div id=\"df-08530a86-7228-4d33-b0af-0f0a546b0eb3\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>question1: What attributes would have made you...</td>\n","      <td>not_duplicate</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>question1: What was it like in Ancient rome? q...</td>\n","      <td>duplicate</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-08530a86-7228-4d33-b0af-0f0a546b0eb3')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-08530a86-7228-4d33-b0af-0f0a546b0eb3 button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-08530a86-7228-4d33-b0af-0f0a546b0eb3');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":10}]},{"cell_type":"markdown","metadata":{"id":"GsvuFTkjlm-N"},"source":["\n","# Task 7 [SST2 - Binary Sentiment Analysis](https://www.aclweb.org/anthology/D13-1170.pdf)\n","Binary sentiment classification.      \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","| Sentence1 | Prediction  | \n","|-----------|-----------|\n","|it confirms fincher ’s status as a film maker who artfully bends technical know-how to the service of psychological insight |  positive| \n","|I really hated that movie | negative | \n","\n","\n","## How to configure T5 task for  SST2\n","`.setTask('sst2 sentence: ')`\n","\n","### Example pre-processed input for T5 SST2 - Binary Sentiment Analysis\n","\n","```\n","sst2\n","sentence: I hated that movie\n","```\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":112},"id":"FPP4pMVQlOtz","outputId":"bdc96b63-b586-4de1-d4fb-edd03bc72f57","executionInfo":{"status":"ok","timestamp":1650023244308,"user_tz":-300,"elapsed":1267,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","\n","t5['t5_transformer'].setTask('sst2 sentence: ') \n","\n","# define Data, add additional tags between sentences\n","data = [\n","              ''' I really hated that movie''',\n","            '''  it confirms fincher ’s status as a film maker who artfully bends technical know-how to the service of psychological insight'''\n","             ]\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":11,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document        t5\n","0                          I really hated that movie  negative\n","1  it confirms fincher ’s status as a film maker ...  positive"],"text/html":["\n","  <div id=\"df-3678e19d-2b19-4aea-8d39-0e31a8f59914\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>I really hated that movie</td>\n","      <td>negative</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>it confirms fincher ’s status as a film maker ...</td>\n","      <td>positive</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-3678e19d-2b19-4aea-8d39-0e31a8f59914')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-3678e19d-2b19-4aea-8d39-0e31a8f59914 button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-3678e19d-2b19-4aea-8d39-0e31a8f59914');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":11}]},{"cell_type":"markdown","metadata":{"id":"dpZQ_H8fl4OV"},"source":["\n","# Task8 [STSB - Regressive semantic sentence similarity](https://www.aclweb.org/anthology/S17-2001/)\n","Measures how similar two sentences are on a scale from 0 to 5 with 21 classes representing a regressive label.     \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf).\n","\n","\n","| Question1 | Question2 | prediction|\n","|------------|------------|----------|\n","|What attributes would have made you highly desirable in ancient Rome?        | How I GET OPPERTINUTY TO JOIN IT COMPANY AS A FRESHER? | 0 | \n","|What was it like in Ancient rome?  | What was Ancient rome like?| 5.0 | \n","|What was live like as a King in Ancient Rome??       | What is it like to live in Rome? | 3.2 | \n","\n","## How to configure T5 task for STSB\n","`.setTask('stsb sentence1:)` and prefix second sentence with `sentence2:`\n","\n","\n","### Example pre-processed input for T5 STSB - Regressive semantic sentence similarity\n","\n","```\n","stsb\n","sentence1: What attributes would have made you highly desirable in ancient Rome?        \n","sentence2: How I GET OPPERTINUTY TO JOIN IT COMPANY AS A FRESHER?',\n","```"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":143},"id":"yPODqDWYl35B","outputId":"89e390a7-60dc-465f-f4d4-21630e27338f","executionInfo":{"status":"ok","timestamp":1650023248078,"user_tz":-300,"elapsed":3815,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('stsb ') \n","\n","\n","# define Data, add additional tags between sentences\n","data = [\n","             \n","              ''' sentence1:  What attributes would have made you highly desirable in ancient Rome?  \n","                  sentence2:  How I GET OPPERTINUTY TO JOIN IT COMPANY AS A FRESHER?'\n","              '''\n","             ,\n","             '''  \n","              sentence1: What was it like in Ancient rome?\n","              sentence2: \tWhat was Ancient rome like?\n","              ''',\n","              '''  \n","              sentence1: What was live like as a King in Ancient Rome??\n","              sentence2: \tWhat was Ancient rome like?\n","              '''\n","\n","             ]\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":12,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document   t5\n","0  sentence1: What attributes would have made you...  0.0\n","1  sentence1: What was it like in Ancient rome? s...  5.0\n","2  sentence1: What was live like as a King in Anc...  3.2"],"text/html":["\n","  <div id=\"df-0d745e6a-56e9-4d78-8b6f-3e682384d342\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>sentence1: What attributes would have made you...</td>\n","      <td>0.0</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>sentence1: What was it like in Ancient rome? s...</td>\n","      <td>5.0</td>\n","    </tr>\n","    <tr>\n","      <th>2</th>\n","      <td>sentence1: What was live like as a King in Anc...</td>\n","      <td>3.2</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-0d745e6a-56e9-4d78-8b6f-3e682384d342')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-0d745e6a-56e9-4d78-8b6f-3e682384d342 button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-0d745e6a-56e9-4d78-8b6f-3e682384d342');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":12}]},{"cell_type":"markdown","metadata":{"id":"2pGz7_qsmQUF"},"source":["\n","# Task 9[ CB -  Natural language inference contradiction classification](https://ojs.ub.uni-konstanz.de/sub/index.php/sub/article/view/601)\n","Classify whether a Premise contradicts a Hypothesis.    \n","Predicts entailment, neutral and contradiction     \n","This is a sub-task of [SuperGLUE](https://w4ngatang.github.io/static/papers/superglue.pdf).\n","\n","\n","| Hypothesis | Premise | Prediction | \n","|--------|-------------|----------|\n","|Valence was helping | Valence the void-brain, Valence the virtuous valet. Why couldn’t the figger choose his own portion of titanic anatomy to shaft? Did he think he was helping'| Contradiction|\n","\n","\n","## How to configure T5 task for CB\n","`.setTask('cb hypothesis:)` and prefix premise with `premise:`\n","\n","### Example pre-processed input for T5 CB -  Natural language inference contradiction classification\n","\n","```\n","cb \n","hypothesis: Valence was helping      \n","premise: Valence the void-brain, Valence the virtuous valet. Why couldn’t the figger choose his own portion of titanic anatomy to shaft? Did he think he was helping,\n","```\n","\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":81},"id":"XjGzx2v8l2lk","outputId":"1822992d-d226-4f5e-dfee-9ecd86d9ceeb","executionInfo":{"status":"ok","timestamp":1650023248756,"user_tz":-300,"elapsed":704,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('cb ') \n","\n","\n","# define Data, add additional tags between sentences\n","data = [\n","              '''\n","              hypothesis: Recent report say Johnny makes he alot of money, he earned 10 million USD each year for the last 5 years.\n","              premise: Johnny is a poor man.\n","                            ''']\n","\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":13,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document             t5\n","0  hypothesis: Recent report say Johnny makes he ...  contradiction"],"text/html":["\n","  <div id=\"df-f77836c8-e54c-4aa5-9dcd-f1924954a43e\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>hypothesis: Recent report say Johnny makes he ...</td>\n","      <td>contradiction</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-f77836c8-e54c-4aa5-9dcd-f1924954a43e')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-f77836c8-e54c-4aa5-9dcd-f1924954a43e button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-f77836c8-e54c-4aa5-9dcd-f1924954a43e');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":13}]},{"cell_type":"markdown","metadata":{"id":"Q8Zg4o7NnDy7"},"source":["\n","# Task 10 [COPA - Sentence Completion/ Binary choice selection](https://www.aaai.org/ocs/index.php/SSS/SSS11/paper/view/2418/0)\n","The Choice of Plausible Alternatives (COPA) task by Roemmele et al. (2011) evaluates\n","causal reasoning between events, which requires commonsense knowledge about what usually takes\n","place in the world. Each example provides a premise and either asks for the correct cause or effect\n","from two choices, thus testing either ``backward`` or `forward causal reasoning`. COPA data, which\n","consists of 1,000 examples total, can be downloaded at https://people.ict.usc.e\n","\n","This is a sub-task of [SuperGLUE](https://w4ngatang.github.io/static/papers/superglue.pdf).\n","\n","This classifier selects from a choice of `2 options` which one the correct is based on a `premise`.\n","\n","\n","## forward causal reasoning\n","Premise: The man lost his balance on the ladder.     \n","question: What happened as a result?        \n","Alternative 1: He fell off the ladder.       \n","Alternative 2: He climbed up the ladder.\n","## backwards causal reasoning\n","Premise: The man fell unconscious. What was the cause\n","of this?       \n","Alternative 1: The assailant struck the man in the head.      \n","Alternative 2: The assailant took the man’s wallet.\n","\n","\n","| Question | Premise | Choice 1 | Choice  2 | Prediction | \n","|--------|-------------|----------|---------|-------------|\n","|effect | Politcal Violence broke out in the nation. | many citizens relocated to the capitol. |  Many citizens took refuge in other territories | Choice 1  | \n","|correct| The men fell unconscious | The assailant struckl the man in the head | he assailant s took the man's wallet. | choice1 | \n","\n","\n","## How to configure T5 task for COPA\n","`.setTask('copa choice1:)`, prefix choice2 with `choice2:` , prefix premise with `premise:` and prefix the question with `question`\n","\n","### Example pre-processed input for T5 COPA - Sentence Completion/ Binary choice selection\n","\n","```\n","copa \n","choice1:   He fell off the ladder    \n","choice2:   He climbed up the lader       \n","premise:   The man lost his balance on the ladder \n","question:  effect\n","```\n","\n","\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":81},"id":"bTt90f0pmtxi","outputId":"10a364d4-ef1d-4f3e-a7dc-04ac37c1149c","executionInfo":{"status":"ok","timestamp":1650023250185,"user_tz":-300,"elapsed":1438,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('copa ') \n","\n","\n","# define Data, add additional tags between sentences\n","data = [\n","              '''\n","            choice1:   He fell off the ladder    \n","            choice2:   He climbed up the lader       \n","            premise:   The man lost his balance on the ladder \n","            question:  effect\n","\n","                            ''']\n","\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":14,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document       t5\n","0  choice1: He fell off the ladder choice2: He cl...  choice1"],"text/html":["\n","  <div id=\"df-b3fd7592-c312-45e4-b25b-6f3e8768767a\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>choice1: He fell off the ladder choice2: He cl...</td>\n","      <td>choice1</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-b3fd7592-c312-45e4-b25b-6f3e8768767a')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-b3fd7592-c312-45e4-b25b-6f3e8768767a button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-b3fd7592-c312-45e4-b25b-6f3e8768767a');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":14}]},{"cell_type":"markdown","metadata":{"id":"MtTZAk02nR16"},"source":["\n","# Task 11 [MultiRc - Question Answering](https://www.aclweb.org/anthology/N18-1023.pdf)\n","Evaluates an `answer` for a `question` as `true` or `false` based on an input `paragraph`\n","The T5 model predicts for a `question` and a `paragraph` of `sentences` wether an `answer` is true or not,\n","based on the semantic contents of the paragraph.        \n","This is a sub-task of [SuperGLUE](https://w4ngatang.github.io/static/papers/superglue.pdf).\n","\n","\n","\n","**Exeeds human performance by a large margin**\n","\n","\n","\n","| Question                                                     | Answer                                                              | Prediction | paragraph|\n","|--------------------------------------------------------------|---------------------------------------------------------------------|------------|----------|\n","| Why was Joey surprised the morning he woke up for breakfast? | There was only pie to eat, rather than traditional breakfast foods  |  True   |Once upon a time, there was a squirrel named Joey. Joey loved to go outside and play with his cousin Jimmy. Joey and Jimmy played silly games together, and were always laughing. One day, Joey and Jimmy went swimming together 50 at their Aunt Julie’s pond. Joey woke up early in the morning to eat some food before they left. He couldn’t find anything to eat except for pie! Usually, Joey would eat cereal, fruit (a pear), or oatmeal for breakfast. After he ate, he and Jimmy went to the pond. On their way there they saw their friend Jack Rabbit. They dove into the water and swam for several hours. The sun was out, but the breeze was cold. Joey and Jimmy got out of the water and started walking home. Their fur was wet, and the breeze chilled them. When they got home, they dried off, and Jimmy put on his favorite purple shirt. Joey put on a blue shirt with red and green dots. The two squirrels ate some food that Joey’s mom, Jasmine, made and went off to bed.,          |\n","| Why was Joey surprised the morning he woke up for breakfast? | There was a T-Rex in his garden  |  False   |Once upon a time, there was a squirrel named Joey. Joey loved to go outside and play with his cousin Jimmy. Joey and Jimmy played silly games together, and were always laughing. One day, Joey and Jimmy went swimming together 50 at their Aunt Julie’s pond. Joey woke up early in the morning to eat some food before they left. He couldn’t find anything to eat except for pie! Usually, Joey would eat cereal, fruit (a pear), or oatmeal for breakfast. After he ate, he and Jimmy went to the pond. On their way there they saw their friend Jack Rabbit. They dove into the water and swam for several hours. The sun was out, but the breeze was cold. Joey and Jimmy got out of the water and started walking home. Their fur was wet, and the breeze chilled them. When they got home, they dried off, and Jimmy put on his favorite purple shirt. Joey put on a blue shirt with red and green dots. The two squirrels ate some food that Joey’s mom, Jasmine, made and went off to bed.,          |\n","\n","## How to configure T5 task for MultiRC\n","`.setTask('multirc questions:)`  followed by `answer:` prefix for the answer to evaluate, followed by `paragraph:` and then a series of sentences, where each sentence is prefixed with `Sent n:`prefix second sentence with sentence2:\n","\n","\n","### Example pre-processed input for T5 MultiRc task:\n","```\n","multirc questions:  Why was Joey surprised the morning he woke up for breakfast?      \n","answer:             There was a T-REX in his garden.      \n","paragraph:      \n","Sent 1:             Once upon a time, there was a squirrel named Joey.      \n","Sent 2:             Joey loved to go outside and play with his cousin Jimmy.      \n","Sent 3:             Joey and Jimmy played silly games together, and were always laughing.      \n","Sent 4:             One day, Joey and Jimmy went swimming together 50 at their Aunt Julie’s pond.      \n","Sent 5:             Joey woke up early in the morning to eat some food before they left.      \n","Sent 6:             He couldn’t find anything to eat except for pie!      \n","Sent 7:             Usually, Joey would eat cereal, fruit (a pear), or oatmeal for breakfast.      \n","Sent 8:             After he ate, he and Jimmy went to the pond.      \n","Sent 9:             On their way there they saw their friend Jack Rabbit.      \n","Sent 10:            They dove into the water and swam for several hours.      \n","Sent 11:            The sun was out, but the breeze was cold.      \n","Sent 12:            Joey and Jimmy got out of the water and started walking home.      \n","Sent 13:            Their fur was wet, and the breeze chilled them.      \n","Sent 14:            When they got home, they dried off, and Jimmy put on his favorite purple shirt.      \n","Sent 15:            Joey put on a blue shirt with red and green dots.      \n","Sent 16:            The two squirrels ate some food that Joey’s mom, Jasmine, made and went off to bed.      \n","```"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":112},"id":"U87YZ46LnNpx","outputId":"8da7e699-2ac3-4f62-d642-a747314f0b75","executionInfo":{"status":"ok","timestamp":1650023256713,"user_tz":-300,"elapsed":6540,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('multirc ') \n","\n","# define Data, add additional tags between sentences\n","data = [\n","              '''\n","questions:  Why was Joey surprised the morning he woke up for breakfast?      \n","answer:             There was a T-REX in his garden.      \n","paragraph:      \n","Sent 1:             Once upon a time, there was a squirrel named Joey.      \n","Sent 2:             Joey loved to go outside and play with his cousin Jimmy.      \n","Sent 3:             Joey and Jimmy played silly games together, and were always laughing.      \n","Sent 4:             One day, Joey and Jimmy went swimming together 50 at their Aunt Julie’s pond.      \n","Sent 5:             Joey woke up early in the morning to eat some food before they left.      \n","Sent 6:             He couldn’t find anything to eat except for pie!      \n","Sent 7:             Usually, Joey would eat cereal, fruit (a pear), or oatmeal for breakfast.      \n","Sent 8:             After he ate, he and Jimmy went to the pond.      \n","Sent 9:             On their way there they saw their friend Jack Rabbit.      \n","Sent 10:            They dove into the water and swam for several hours.      \n","Sent 11:            The sun was out, but the breeze was cold.      \n","Sent 12:            Joey and Jimmy got out of the water and started walking home.      \n","Sent 13:            Their fur was wet, and the breeze chilled them.      \n","Sent 14:            When they got home, they dried off, and Jimmy put on his favorite purple shirt.      \n","Sent 15:            Joey put on a blue shirt with red and green dots.      \n","Sent 16:            The two squirrels ate some food that Joey’s mom, Jasmine, made and went off to bed.      \n","\n","                            ''',\n","             \n","              '''\n","questions:  Why was Joey surprised the morning he woke up for breakfast?      \n","answer:             There was only pie for breakfast.      \n","paragraph:      \n","Sent 1:             Once upon a time, there was a squirrel named Joey.      \n","Sent 2:             Joey loved to go outside and play with his cousin Jimmy.      \n","Sent 3:             Joey and Jimmy played silly games together, and were always laughing.      \n","Sent 4:             One day, Joey and Jimmy went swimming together 50 at their Aunt Julie’s pond.      \n","Sent 5:             Joey woke up early in the morning to eat some food before they left.      \n","Sent 6:             He couldn’t find anything to eat except for pie!      \n","Sent 7:             Usually, Joey would eat cereal, fruit (a pear), or oatmeal for breakfast.      \n","Sent 8:             After he ate, he and Jimmy went to the pond.      \n","Sent 9:             On their way there they saw their friend Jack Rabbit.      \n","Sent 10:            They dove into the water and swam for several hours.      \n","Sent 11:            The sun was out, but the breeze was cold.      \n","Sent 12:            Joey and Jimmy got out of the water and started walking home.      \n","Sent 13:            Their fur was wet, and the breeze chilled them.      \n","Sent 14:            When they got home, they dried off, and Jimmy put on his favorite purple shirt.      \n","Sent 15:            Joey put on a blue shirt with red and green dots.      \n","Sent 16:            The two squirrels ate some food that Joey’s mom, Jasmine, made and went off to bed.      \n","\n","                            '''\n","             ]\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":15,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document     t5\n","0  questions: Why was Joey surprised the morning ...  False\n","1  questions: Why was Joey surprised the morning ...   True"],"text/html":["\n","  <div id=\"df-3a4f67ca-123f-4070-a481-6c706736cf02\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>questions: Why was Joey surprised the morning ...</td>\n","      <td>False</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>questions: Why was Joey surprised the morning ...</td>\n","      <td>True</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-3a4f67ca-123f-4070-a481-6c706736cf02')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-3a4f67ca-123f-4070-a481-6c706736cf02 button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-3a4f67ca-123f-4070-a481-6c706736cf02');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":15}]},{"cell_type":"markdown","metadata":{"id":"KevnNo0pnpaA"},"source":["\n","# Task 12 [WiC - Word sense disambiguation](https://arxiv.org/abs/1808.09121)\n","Decide for `two sentence`s with a shared `disambigous word` wether they have the target word has the same `semantic meaning` in both sentences.       \n","This is a sub-task of [SuperGLUE](https://w4ngatang.github.io/static/papers/superglue.pdf).\n","\n","\n","|Predicted | disambigous word| Sentence 1 | Sentence 2 | \n","|----------|-----------------|------------|------------|\n","| False    | kill            | He totally killed that rock show! | The airplane crash killed his family | \n","| True     | window          | The expanded window will give us time to catch the thieves.|You have a two-hour window for turning in your homework. |     \n","| False     | window          | He jumped out of the window.|You have a two-hour window for turning in your homework. |     \n","\n","\n","## How to configure T5 task for MultiRC\n","`.setTask('wic pos:)`  followed by `sentence1:` prefix for the first sentence, followed by `sentence2:` prefix for the second sentence.\n","\n","\n","### Example pre-processed input for T5  WiC task:\n","\n","```\n","wic pos:\n","sentence1:    The expanded window will give us time to catch the thieves.\n","sentence2:    You have a two-hour window of turning in your homework.\n","word :        window\n","```\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":81},"id":"1KoYaT8cnboA","outputId":"af0b4141-2f7e-4a7a-b2cc-091b085da98e","executionInfo":{"status":"ok","timestamp":1650023257397,"user_tz":-300,"elapsed":689,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('wic ') \n","\n","\n","# define Data, add additional tags between sentences\n","data = [\n","              '''\n","pos:\n","sentence1:    The expanded window will give us time to catch the thieves.\n","sentence2:    You have a two-hour window of turning in your homework.\n","word :        window\n","\n","                            ''',]\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":16,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document    t5\n","0  pos: sentence1: The expanded window will give ...  True"],"text/html":["\n","  <div id=\"df-e5e3a573-d5e9-4896-a93a-091c4a954d9a\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>pos: sentence1: The expanded window will give ...</td>\n","      <td>True</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-e5e3a573-d5e9-4896-a93a-091c4a954d9a')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-e5e3a573-d5e9-4896-a93a-091c4a954d9a button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-e5e3a573-d5e9-4896-a93a-091c4a954d9a');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":16}]},{"cell_type":"markdown","metadata":{"id":"YvcjGf82n39w"},"source":["\n","# Task 13 [WSC and DPR - Coreference resolution/ Pronoun ambiguity resolver  ](https://www.aaai.org/ocs/index.php/KR/KR12/paper/view/4492/0)\n","Predict for an `ambiguous pronoun` to which `noun` it is referring to.     \n","This is a sub-task of [GLUE](https://arxiv.org/pdf/1804.07461.pdf) and [SuperGLUE](https://w4ngatang.github.io/static/papers/superglue.pdf).\n","\n","|Prediction| Text | \n","|----------|-------|\n","| stable   | The stable was very roomy, with four good stalls; a large swinging window opened into the yard , which made *it* pleasant and airy. | \n","\n","\n","\n","## How to configure T5 task for WSC/DPR\n","`.setTask('wsc:)` and surround pronoun with asteriks symbols..\n","\n","\n","### Example pre-processed input for T5  WSC/DPR  task:\n","The `ambiguous pronous` should be surrounded with `*` symbols.\n","\n","***Note*** Read [Appendix A.](https://arxiv.org/pdf/1910.10683.pdf#page=64&zoom=100,84,360) for more info\n","```\n","wsc: \n","The stable was very roomy, with four good stalls; a large swinging window opened into the yard , which made *it* pleasant and airy.\n","```\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":81},"id":"g4ZLodm1nyGQ","outputId":"c96a02d6-e412-4dbd-b60c-79f34ac7739d","executionInfo":{"status":"ok","timestamp":1650023265615,"user_tz":-300,"elapsed":8225,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Does not work yet 100% correct\n","# Set the task on T5\n","t5['t5_transformer'].setTask('wsc ') \n","\n","\n","\n","# define Data, add additional tags between sentences\n","data = ['''The stable was very roomy, with four good stalls; a large swinging window opened into the yard , which made *it* pleasant and airy.''']\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":17,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document  \\\n","0  The stable was very roomy, with four good stal...   \n","\n","                                                  t5  \n","0  wsc The stable was very roomy, with four good ...  "],"text/html":["\n","  <div id=\"df-d45fcb26-da59-429c-864e-69b1cc9d245f\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>The stable was very roomy, with four good stal...</td>\n","      <td>wsc The stable was very roomy, with four good ...</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-d45fcb26-da59-429c-864e-69b1cc9d245f')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-d45fcb26-da59-429c-864e-69b1cc9d245f button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-d45fcb26-da59-429c-864e-69b1cc9d245f');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":17}]},{"cell_type":"markdown","metadata":{"id":"_MyugUXQoJd8"},"source":["\n","# Task 14 [Text summarization](https://arxiv.org/abs/1506.03340)\n","`Summarizes` a paragraph into a shorter version with the same semantic meaning.\n","\n","| Predicted summary| Text | \n","|------------------|-------|\n","| manchester united face newcastle in the premier league on wednesday . louis van gaal's side currently sit two points clear of liverpool in fourth . the belgian duo took to the dance floor on monday night with some friends .            | the belgian duo took to the dance floor on monday night with some friends . manchester united face newcastle in the premier league on wednesday . red devils will be looking for just their second league away win in seven . louis van gaal’s side currently sit two points clear of liverpool in fourth . | \n","\n","\n","## How to configure T5 task for summarization\n","`.setTask('summarize:)`\n","\n","\n","### Example pre-processed input for T5 summarization task:\n","This task requires no pre-processing, setting the task to `summarize` is sufficient.\n","```\n","the belgian duo took to the dance floor on monday night with some friends . manchester united face newcastle in the premier league on wednesday . red devils will be looking for just their second league away win in seven . louis van gaal’s side currently sit two points clear of liverpool in fourth .\n","```\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":112},"id":"hBM0VycaoAnB","outputId":"0ab943bc-6600-4dd0-ec08-e4917c859180","executionInfo":{"status":"ok","timestamp":1650023294874,"user_tz":-300,"elapsed":29269,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('summarize ') \n","\n","\n","\n","# define Data, add additional tags between sentences\n","data = [\n","              '''\n","        The belgian duo took to the dance floor on monday night with some friends . manchester united face newcastle in the premier league on wednesday . red devils will be looking for just their second league away win in seven . louis van gaal’s side currently sit two points clear of liverpool in fourth .\n","                            ''',\n","              '''  Calculus, originally called infinitesimal calculus or \"the calculus of infinitesimals\", is the mathematical study of continuous change, in the same way that geometry is the study of shape and algebra is the study of generalizations of arithmetic operations. It has two major branches, differential calculus and integral calculus; the former concerns instantaneous rates of change, and the slopes of curves, while integral calculus concerns accumulation of quantities, and areas under or between curves. These two branches are related to each other by the fundamental theorem of calculus, and they make use of the fundamental notions of convergence of infinite sequences and infinite series to a well-defined limit.[1] Infinitesimal calculus was developed independently in the late 17th century by Isaac Newton and Gottfried Wilhelm Leibniz.[2][3] Today, calculus has widespread uses in science, engineering, and economics.[4] In mathematics education, calculus denotes courses of elementary mathematical analysis, which are mainly devoted to the study of functions and limits. The word calculus (plural calculi) is a Latin word, meaning originally \"small pebble\" (this meaning is kept in medicine – see Calculus (medicine)). Because such pebbles were used for calculation, the meaning of the word has evolved and today usually means a method of computation. It is therefore used for naming specific methods of calculation and related theories, such as propositional calculus, Ricci calculus, calculus of variations, lambda calculus, and process calculus.'''\n","             ]\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":18,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document  \\\n","0  The belgian duo took to the dance floor on mon...   \n","1  Calculus, originally called infinitesimal calc...   \n","\n","                                                  t5  \n","0  manchester united face newcastle in the premie...  \n","1  calculus, originally called infinitesimal calc...  "],"text/html":["\n","  <div id=\"df-2b47ada1-2f2e-4952-bfc5-dde662f5a1a1\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>The belgian duo took to the dance floor on mon...</td>\n","      <td>manchester united face newcastle in the premie...</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>Calculus, originally called infinitesimal calc...</td>\n","      <td>calculus, originally called infinitesimal calc...</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-2b47ada1-2f2e-4952-bfc5-dde662f5a1a1')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-2b47ada1-2f2e-4952-bfc5-dde662f5a1a1 button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-2b47ada1-2f2e-4952-bfc5-dde662f5a1a1');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":18}]},{"cell_type":"markdown","metadata":{"id":"ZyxqNOO1obBv"},"source":["\n","# Task 15 [SQuAD - Context based question answering](https://arxiv.org/abs/1606.05250)\n","Predict an `answer` to a `question` based on input `context`.\n","\n","|Predicted Answer | Question | Context | \n","|-----------------|----------|------|\n","|carbon monoxide| What does increased oxygen concentrations in the patient’s lungs displace? | Hyperbaric (high-pressure) medicine uses special oxygen chambers to increase the partial pressure of O 2 around the patient and, when needed, the medical staff. Carbon monoxide poisoning, gas gangrene, and decompression sickness (the ’bends’) are sometimes treated using these devices. Increased O 2 concentration in the lungs helps to displace carbon monoxide from the heme group of hemoglobin. Oxygen gas is poisonous to the anaerobic bacteria that cause gas gangrene, so increasing its partial pressure helps kill them. Decompression sickness occurs in divers who decompress too quickly after a dive, resulting in bubbles of inert gas, mostly nitrogen and helium, forming in their blood. Increasing the pressure of O 2 as soon as possible is part of the treatment.\n","|pie| What did Joey eat for breakfast?| Once upon a time, there was a squirrel named Joey. Joey loved to go outside and play with his cousin Jimmy. Joey and Jimmy played silly games together, and were always laughing. One day, Joey and Jimmy went swimming together 50 at their Aunt Julie’s pond. Joey woke up early in the morning to eat some food before they left. Usually, Joey would eat cereal, fruit (a pear), or oatmeal for breakfast. After he ate, he and Jimmy went to the pond. On their way there they saw their friend Jack Rabbit. They dove into the water and swam for several hours. The sun was out, but the breeze was cold. Joey and Jimmy got out of the water and started walking home. Their fur was wet, and the breeze chilled them. When they got home, they dried off, and Jimmy put on his favorite purple shirt. Joey put on a blue shirt with red and green dots. The two squirrels ate some food that Joey’s mom, Jasmine, made and went off to bed,'|  \n","\n","## How to configure T5 task parameter for Squad Context based question answering\n","`.setTask('question:)` and prefix the context which can be made up of multiple sentences with `context:`\n","\n","## Example pre-processed input for T5 Squad Context based question answering:\n","```\n","question: What does increased oxygen concentrations in the patient’s lungs displace? \n","context: Hyperbaric (high-pressure) medicine uses special oxygen chambers to increase the partial pressure of O 2 around the patient and, when needed, the medical staff. Carbon monoxide poisoning, gas gangrene, and decompression sickness (the ’bends’) are sometimes treated using these devices. Increased O 2 concentration in the lungs helps to displace carbon monoxide from the heme group of hemoglobin. Oxygen gas is poisonous to the anaerobic bacteria that cause gas gangrene, so increasing its partial pressure helps kill them. Decompression sickness occurs in divers who decompress too quickly after a dive, resulting in bubbles of inert gas, mostly nitrogen and helium, forming in their blood. Increasing the pressure of O 2 as soon as possible is part of the treatment.\n","```\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":81},"id":"OiotszcWoY4r","outputId":"67333c75-3a59-4317-c030-8f6fb531f65a","executionInfo":{"status":"ok","timestamp":1650023299131,"user_tz":-300,"elapsed":4277,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('question ') \n","\n","\n","# define Data, add additional tags between sentences\n","data = ['''\n","What does increased oxygen concentrations in the patient’s lungs displace? \n","context: Hyperbaric (high-pressure) medicine uses special oxygen chambers to increase the partial pressure of O 2 around the patient and, when needed, the medical staff. Carbon monoxide poisoning, gas gangrene, and decompression sickness (the ’bends’) are sometimes treated using these devices. Increased O 2 concentration in the lungs helps to displace carbon monoxide from the heme group of hemoglobin. Oxygen gas is poisonous to the anaerobic bacteria that cause gas gangrene, so increasing its partial pressure helps kill them. Decompression sickness occurs in divers who decompress too quickly after a dive, resulting in bubbles of inert gas, mostly nitrogen and helium, forming in their blood. Increasing the pressure of O 2 as soon as possible is part of the treatment.\n","''']\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":19,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document               t5\n","0  What does increased oxygen concentrations in t...  carbon monoxide"],"text/html":["\n","  <div id=\"df-de34b1b4-8d85-4181-9282-5db42f3ea1b7\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>What does increased oxygen concentrations in t...</td>\n","      <td>carbon monoxide</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-de34b1b4-8d85-4181-9282-5db42f3ea1b7')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-de34b1b4-8d85-4181-9282-5db42f3ea1b7 button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-de34b1b4-8d85-4181-9282-5db42f3ea1b7');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":19}]},{"cell_type":"code","metadata":{"id":"ZRWahi-cop_w","executionInfo":{"status":"ok","timestamp":1650023299131,"user_tz":-300,"elapsed":6,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":[""],"execution_count":19,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"EV4YUQdkoqXw"},"source":["# Task 16 [WMT1 Translate English to German](https://arxiv.org/abs/1706.03762)\n","For translation tasks use the `marian` model\n","## How to configure T5 task parameter for WMT Translate English to German\n","`.setTask('translate English to German:)`\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":81},"id":"2aEz3xiGombi","outputId":"0bbd071d-8377-450f-889e-5c0c2e5d1cfc","executionInfo":{"status":"ok","timestamp":1650023315182,"user_tz":-300,"elapsed":16056,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('translate English to German: ') \n","\n","\n","# define Data, add additional tags between sentences\n","sentences = ['''I like sausage and Tea for breakfast with potatoes''']\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":20,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document  \\\n","0  What does increased oxygen concentrations in t...   \n","\n","                                              t5  \n","0  Die heutige Variante des Oxygen-Stahls bietet  "],"text/html":["\n","  <div id=\"df-5facff87-5c1a-4446-8001-b4d249c537c7\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>What does increased oxygen concentrations in t...</td>\n","      <td>Die heutige Variante des Oxygen-Stahls bietet</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-5facff87-5c1a-4446-8001-b4d249c537c7')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-5facff87-5c1a-4446-8001-b4d249c537c7 button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-5facff87-5c1a-4446-8001-b4d249c537c7');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":20}]},{"cell_type":"markdown","metadata":{"id":"kZQe18dQo3CH"},"source":["# Task 17 [WMT2 Translate English to French](https://arxiv.org/abs/1706.03762)\n","For translation tasks use the `marian` model\n","## How to configure T5 task parameter for WMT Translate English to French\n","`.setTask('translate English to French:)`"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":81},"id":"SaSJkuK8o1sL","outputId":"af119d91-1884-40e3-b9e8-c8e9a53faa8b","executionInfo":{"status":"ok","timestamp":1650023321891,"user_tz":-300,"elapsed":6727,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('translate English to French: ') \n","\n","\n","# define Data, add additional tags between sentences\n","data = ['''I like sausage and Tea for breakfast with potatoes''']\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":21,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document  \\\n","0  I like sausage and Tea for breakfast with pota...   \n","\n","                                                  t5  \n","0  J'aime les saucisses et le thé au petit déjeun...  "],"text/html":["\n","  <div id=\"df-4edc1748-81a5-4681-93eb-224d0c5f1e3d\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>I like sausage and Tea for breakfast with pota...</td>\n","      <td>J'aime les saucisses et le thé au petit déjeun...</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-4edc1748-81a5-4681-93eb-224d0c5f1e3d')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-4edc1748-81a5-4681-93eb-224d0c5f1e3d button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-4edc1748-81a5-4681-93eb-224d0c5f1e3d');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":21}]},{"cell_type":"markdown","metadata":{"id":"_nozgTDFo7cK"},"source":["# 18 [WMT3 - Translate English to Romanian](https://arxiv.org/abs/1706.03762)\n","For translation tasks use the `marian` model\n","## How to configure T5 task parameter for English to Romanian\n","`.setTask('translate English to Romanian:)`"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":81},"id":"_879n2Ljo5tc","outputId":"342df3ff-35fa-4ccf-c100-1ac76c9149c0","executionInfo":{"status":"ok","timestamp":1650023328590,"user_tz":-300,"elapsed":6731,"user":{"displayName":"Gammer Otaku","userId":"18042713576744284398"}}},"source":["# Set the task on T5\n","t5['t5_transformer'].setTask('translate English to Romanian: ') \n","\n","# define Data, add additional tags between sentences\n","data = [ '''I like sausage and Tea for breakfast with potatoes''']\n","\n","\n","#Predict on text data with T5\n","t5.predict(data)"],"execution_count":22,"outputs":[{"output_type":"execute_result","data":{"text/plain":["                                            document  \\\n","0  I like sausage and Tea for breakfast with pota...   \n","\n","                                                  t5  \n","0  Mi-ar plăcea cârnaţi şi ceai la micul dejun cu...  "],"text/html":["\n","  <div id=\"df-b12df835-3644-4bcc-907d-165b1f0e965b\">\n","    <div class=\"colab-df-container\">\n","      <div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>document</th>\n","      <th>t5</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>I like sausage and Tea for breakfast with pota...</td>\n","      <td>Mi-ar plăcea cârnaţi şi ceai la micul dejun cu...</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>\n","      <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-b12df835-3644-4bcc-907d-165b1f0e965b')\"\n","              title=\"Convert this dataframe to an interactive table.\"\n","              style=\"display:none;\">\n","        \n","  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n","       width=\"24px\">\n","    <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n","    <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n","  </svg>\n","      </button>\n","      \n","  <style>\n","    .colab-df-container {\n","      display:flex;\n","      flex-wrap:wrap;\n","      gap: 12px;\n","    }\n","\n","    .colab-df-convert {\n","      background-color: #E8F0FE;\n","      border: none;\n","      border-radius: 50%;\n","      cursor: pointer;\n","      display: none;\n","      fill: #1967D2;\n","      height: 32px;\n","      padding: 0 0 0 0;\n","      width: 32px;\n","    }\n","\n","    .colab-df-convert:hover {\n","      background-color: #E2EBFA;\n","      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n","      fill: #174EA6;\n","    }\n","\n","    [theme=dark] .colab-df-convert {\n","      background-color: #3B4455;\n","      fill: #D2E3FC;\n","    }\n","\n","    [theme=dark] .colab-df-convert:hover {\n","      background-color: #434B5C;\n","      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n","      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n","      fill: #FFFFFF;\n","    }\n","  </style>\n","\n","      <script>\n","        const buttonEl =\n","          document.querySelector('#df-b12df835-3644-4bcc-907d-165b1f0e965b button.colab-df-convert');\n","        buttonEl.style.display =\n","          google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n","        async function convertToInteractive(key) {\n","          const element = document.querySelector('#df-b12df835-3644-4bcc-907d-165b1f0e965b');\n","          const dataTable =\n","            await google.colab.kernel.invokeFunction('convertToInteractive',\n","                                                     [key], {});\n","          if (!dataTable) return;\n","\n","          const docLinkHtml = 'Like what you see? Visit the ' +\n","            '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n","            + ' to learn more about interactive tables.';\n","          element.innerHTML = '';\n","          dataTable['output_type'] = 'display_data';\n","          await google.colab.output.renderOutput(dataTable, element);\n","          const docLink = document.createElement('div');\n","          docLink.innerHTML = docLinkHtml;\n","          element.appendChild(docLink);\n","        }\n","      </script>\n","    </div>\n","  </div>\n","  "]},"metadata":{},"execution_count":22}]}]}